import Vue from "vue";
import Vuex from "vuex";
import modules from "./modules";
import permission from "./modules/permission";
Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    get Token() {
      return localStorage.getItem("token");
    },
    set Token(newVal) {
      localStorage.setItem("token", newVal);
    },
    selectedMenus: [],
    unSelectedMenus: [],
    dataCase: ""
    // Token: ""
  },
  getters: {
    getSelectedMenus(state) {
      return state.selectedMenus;
    },
    getUnSelectedMenus(state) {
      return state.unSelectedMenus;
    },
    getDataCase(state) {
      return state.dataCase;
    }
  },
  mutations: {
    setSelectedMenus(state, newVal) {
      state.selectedMenus = newVal;
    },
    setUnSelectedMenus(state, newVal) {
      state.unSelectedMenus = newVal;
    },
    setDataCase(state, newVal) {
      state.dataCase = newVal;
    },
    LOGIN_IN(state, newVal) {
      state.Token = newVal;
    },
    LOGIN_OUT(state) {
      state.Token = "";
      // this.commit("permission/CLEAR_PERMISSION");
      // this.commit("permission/CLEAR_MENU");
    }
  },
  modules
});
